/*
 * This file is part of the Sx Framework Library.
 * 
 * Copyright (C) 2013 University of Colorado Denver
 * <min.choi@ucdenver.edu> <shane.transue@ucdenver.edu>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy 
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
 * copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in 
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 */
#include <sxInteger.h>
#include <limits>

Sx::Integer::Integer() {
	this->value = 0;
}

Sx::Integer::Integer(const Integer& i) {
	this->value = i.value;
}

Sx::Integer::Integer(int value) {
	this->value = value;
}

Sx::Integer::Integer(float value) {
	this->value = static_cast<int>(value);
}

Sx::Integer::Integer(short value) {
	this->value = static_cast<int>(value);
}

Sx::Integer::Integer(long value) {
	this->value = static_cast<int>(value);
}

Sx::Integer::~Integer() {}

void Sx::Integer::set(int value) {
	this->value = value;
}

int Sx::Integer::data() const {
	return this->value;
}

Sx::Integer::operator int () const {
	return this->value;
}

Sx::Integer Sx::Integer::Max() {
	return std::numeric_limits<int>::max();
}

Sx::Integer Sx::Integer::Min() {
	return std::numeric_limits<int>::min();
}

Sx::Integer Sx::Integer::Infinity() {
	return std::numeric_limits<int>::infinity();
}

unsigned long Sx::Integer::ToUnsignedLong(const Integer& i) {
	return static_cast<unsigned long>(i.value);
}

Sx::Integer Sx::Integer::operator + (const Integer& i) {
	return Integer(this->value + i.value);
}

Sx::Integer Sx::Integer::operator + (int i) {
	return Integer(this->value + i);
}

Sx::Integer Sx::Integer::operator - (const Integer& i) {
	return Integer(this->value - i.value);
}

Sx::Integer Sx::Integer::operator - (int i) {
	return Integer(this->value - i);
}

Sx::Integer Sx::Integer::operator * (const Integer& i) {
	return Integer(this->value * i.value);
}

Sx::Integer Sx::Integer::operator * (int i) {
	return Integer(this->value * i);
}

Sx::Integer Sx::Integer::operator / (const Integer& i) {
	return Integer(this->value / i.value);
}

Sx::Integer Sx::Integer::operator / (int i) {
	return Integer(this->value / i);
}

void Sx::Integer::operator += (const Integer& i) {
	this->value += i.value;
}

void Sx::Integer::operator += (int i) {
	this->value += i;
}

void Sx::Integer::operator -= (const Integer& i) {
	this->value -= i.value;
}

void Sx::Integer::operator -= (int i) {
	this->value -= i;
}

void Sx::Integer::operator *= (const Integer& i) {
	this->value *= i.value;
}

void Sx::Integer::operator *= (int i) {
	this->value *= i;
}

void Sx::Integer::operator /= (const Integer& i) {
	this->value /= i.value;
}

void Sx::Integer::operator /= (int i) {
	this->value /= i;
}

void Sx::Integer::operator = (const Integer& i) {
	this->value = i.value;
}

void Sx::Integer::operator = (int i) {
	this->value = i;
}

bool Sx::Integer::operator == (const Integer& i) {
	if ( this->value == i.value ) return true;
	else return false;
}

bool Sx::Integer::operator != (const Integer& i) {
	if ( this->value == i.value ) return false;
	else return true;
}

bool Sx::Integer::operator == (int i) {
	if ( this->value == i ) return true;
	else return false;
}

bool Sx::Integer::operator != (int i) {
	if ( this->value == i ) return false;
	else return true;
}

bool Sx::Integer::operator <= (const Integer& i) {
	if ( this->value <= i.value ) return true;
	else return false;
}

bool Sx::Integer::operator <= (int i) {
	if ( this->value <= i ) return true;
	else return false;
}

bool Sx::Integer::operator >= (const Integer& i) {
	if ( this->value >= i.value ) return true;
	else return false;
}

bool Sx::Integer::operator >= (int i) {
	if ( this->value >= i ) return true;
	else return false;
}

bool Sx::Integer::operator < (const Integer &i) {
	if ( this->value < i.value ) return true;
	else return false;
}

bool Sx::Integer::operator < (int i) {
	if ( this->value < i ) return true;
	else return false;
}

bool Sx::Integer::operator > (const Integer &i) {
	if ( this->value > i.value ) return true;
	else return false;
}

bool Sx::Integer::operator > (int i) {
	if ( this->value > i ) return true;
	else return false;
}

Sx::Integer operator + (int v, const Sx::Integer& i) {
	Sx::Integer r(v);
	r += i;
	return r;
}

Sx::Integer operator - (int v, const Sx::Integer& i) {
	Sx::Integer r(v);
	r -= i;
	return r;
}

Sx::Integer operator * (int v, const Sx::Integer& i) {
	Sx::Integer r(v);
	r *= i;
	return r;
}

Sx::Integer operator / (int v, const Sx::Integer& i) {
	Sx::Integer r(v);
	r /= i;
	return r;
}

std::ostream& operator << (std::ostream &out, const Sx::Integer& i) {
	out << static_cast<int>(i);
	return out;
}
